from typing import List


class Solution:
    def maxScoreSightseeingPair(self, A: List[int]) -> int:
        if not A:
            return 0
        la = len(A)
        # b = [A[0]]
        # for i in range(1, la):
        #     b.append(max(b[i-1], A[i] + i))
        b = A[0]
        ans = 0
        for i in range(1, la):
            ans = max(b + A[i] - i, ans)
            b = max(b, A[i] + i)
        return ans


solve = Solution()
a0 = [8, 1, 5, 2, 6]
print(a0)
print(solve.maxScoreSightseeingPair(a0))


